package com.zztl.infiniteBand.base

import android.os.Bundle
import com.zztl.infiniteBand.ui.view.mvpview.MvpView


/**
 * @desc
 * @auth ${user}
 * @time 2018/6/4  10:58
 */
abstract class BaseMvpActivity<V : MvpView, P : BasePresenter<V>> : BaseActivity() {
    protected var presenter: P? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        presenter = createPresenter()
        if (null != presenter) {
            presenter!!.attachView(this as V)
        }
        super.onCreate(savedInstanceState)
    }

    protected abstract fun createPresenter(): P

    override fun onDestroy() {
        super.onDestroy()
        if (null != presenter) {
            presenter!!.detachView()
            presenter = null
        }
    }
}
